package com.quik.web.worker.mapper;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import org.springframework.stereotype.Repository;

import com.quik.backend.mapper.BaseDao;
import com.quik.entity.DtaWorker;
import com.quik.entity.DtaWorkerType;

/**
 * 功能说明：
 *        技师的数据持久类
 * @author Jenny
 *
 */
@Repository
public class WorkerDao extends BaseDao<DtaWorker> {
	/**
	 * 根据条件查询技师类型数量
	 * @param workerTypeName
	 * @param printerNo
	 * @return
	 * @throws Exception
	 */
	public int findWorkerTypeCount(String workerTypeName, Integer printerNo) throws Exception{
		Map map = new HashMap(2);
		map.put("workerTypeName", workerTypeName == null ? null : workerTypeName.trim());
		map.put("printerNo", printerNo);
		
        int count = (Integer)get("findWorkerTypeCount", map);
        return count;
	}
	
	/**
	 * 根据条件查询技师类型列表（分页）
	 * @param workerTypeName
	 * @param printerNo
	 * @param intPage
	 * @param pageSize
	 * @return
	 * @throws Exception
	 */
	public List findWorkerType(String workerTypeName, Integer printerNo, Integer intPage, Integer pageSize) throws Exception{
		Map map = new HashMap(2);
		map.put("workerTypeName", workerTypeName == null ? null : workerTypeName.trim());
		map.put("printerNo", printerNo);
		map.put("currPage", intPage == null ? null: (intPage - 1) * pageSize);
		map.put("pageSize", pageSize);
		
		List list = load("findWorkerType", map);
		return list;
	}
	
	/**
	 * 根据技师类型名称查询类型数量
	 * @param workerType
	 * @return
	 * @throws Exception
	 */
	public int findWorkerTypeCountByTypeName(String workerType) throws Exception{
		int count = (Integer)get("findWorkerTypeCountByTypeName", (Object)workerType);
		return count;
	}
	
	/**
	 * 新增技师类型
	 * @param workerType
	 * @throws Exception
	 */
	public void addWorkerType(DtaWorkerType workerType) throws Exception{
		add("addWorkerType", workerType);
	}
	
	/**
	 * 根据条件查询技师数量
	 * @param workerNo
	 * @param workerName
	 * @param workerTypeId
	 * @param workerStatus
	 * @return
	 * @throws Exception
	 */
	public int findWorkerCount(String workerNo, String workerName, Integer workerTypeId, String workerStatus) throws Exception{
		Map map = new HashMap(4);
		map.put("workerNo", workerNo == null ? null : workerNo.trim());
		map.put("workerName", workerName == null ? null : workerName.trim());
		map.put("workerTypeId", workerTypeId);
		map.put("workerStatus", workerStatus);
		
		int count = (Integer)get("findWorkerCount", map);
		return count;
	}
	
	/**
	 * 根据条件查询技师列表（分页）
	 * @param workerNo
	 * @param workerName
	 * @param workerTypeId
	 * @param workerStatus
	 * @param intPage
	 * @param pageSize
	 * @return
	 * @throws Exception
	 */
	public List findWorker(String workerNo, String workerName, Integer workerTypeId, String workerStatus, Integer intPage, Integer pageSize) throws  Exception{
		Map map = new HashMap(6);
		map.put("workerNo", workerNo == null ? null : workerNo.trim());
		map.put("workerName", workerName == null ? null : workerName.trim());
		map.put("workerTypeId", workerTypeId);
		map.put("workerStatus", workerStatus);
		map.put("currPage", (intPage - 1) * pageSize);
		map.put("pageSize", pageSize);
		
		List list = load("findWorker", map);
		return list;
	}

	public List<DtaWorker> findAllWorker() throws  Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		List<DtaWorker> list = load("findAllWorker", map);
		return list;
	}
	/**
	 * 根据技师编号查询技师数量
	 * @param workerNo
	 * @return
	 * @throws Exception
	 */
	public int findWorkerCountByWorkerNo(String workerNo) throws Exception{
		int count = (Integer)get("findWorkerCountByWorkerNo", (Object)workerNo);
		return count;
	}
	
	/**
	 * 新增技师
	 * @param worker
	 * @throws Exception
	 */
	public void addWorker(DtaWorker worker) throws Exception{
		add("addWorker", worker);
	}
}
